24. Exercise: Code Your Own Selector
Code Your Own Touch Selector
In this exercise, you'll create and add a touch selector to items in a RecyclerView, which will improve the interactivity of the layout.
Exercise Code
Exercise: T12.04-Exercise-TouchSelector
SOLUTION:
- Create a new selector resource in the drawables folder, named list_item_selector
- Add three items for pressed, activated, and selected states with a drawable background color of colorPrimaryLight
- Add one more item for the default, unselected, background color
- In the list item xml, set the touch selector as the background property of the layout